package www.albertzhe.askForLeave.responsibility;

import www.albertzhe.askForLeave.Chain;
import www.albertzhe.askForLeave.Ratify;
import www.albertzhe.askForLeave.impl.Request;
import www.albertzhe.askForLeave.impl.Result;

/**
 * 组长（级别最小）
 */
public class GroupLeader implements Ratify {

    @Override
    public Result deal(Chain chain) {
        Request request = chain.request();
        System.out.println("“组长” 正在查看请求：" + request.toString());

        if (request.getDays() > 1) { // 并且继续传递下一级
            request.setManagerInfo(request.getManagerInfo() + "作为组长，我同意。");
            return chain.proceed(request);
        }

        return new Result(true, "GroupLeader：早去早回");
    }
}
